package com.wasin.server.quarter;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.springframework.stereotype.Component;

/**
 * @ 作者： wasin
 * @ 创建时间： 2021/9/26  9:58
 * @ 说明：    定时任务
 * @ 当前版本:  1.0.0
 */
@Component
@Slf4j
public class TaskJob implements Job {

    //这些参数都可以在上面定义的类中传过来

    private String taskId;

    private String content;
    private String content2;

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }
    public void setContent(String content){
        this.content=content;
    }
    public void setContent2(String content2){
        this.content2=content2;
    }

    @SneakyThrows
    @Override
    public void execute(JobExecutionContext jobExecutionContext){
        JobDataMap mergedJobDataMap = jobExecutionContext.getMergedJobDataMap();
        log.info("定时任务执行 taskId={}",mergedJobDataMap.get("taskId"));
        // log.info("定时任务执行 taskId={}",taskId);
        System.out.println("定时任务执行："+taskId);
        System.out.println("定时任务执行内容："+content);
        System.out.println("定时任务执行内容2："+content2);
        //执行具体的业务逻辑

    }
}
